﻿/******************************************************************************
 *
 * @copyright:          Copyright 2011 UniSky Ltd.
 * @file:
 * @author:              kenping.liu
 * @creation:
 * @description:
 *
 * @modifications
 * date         user                description
 *
 *
 * @more-details
 *
 *****************************************************************************/
#ifndef _UNISKY_UTIL_H_
#define _UNISKY_UTIL_H_

#include "u_util_str.h"
#include "u_util_args.h"

U_NAMESPACE_BEGIN(u)
U_NAMESPACE_BEGIN(util)
typedef struct _st_u_time_
{
    UINT year;
    UINT month;
    UINT day;
    UINT hour;
    UINT minute;
    UINT second;
    UINT milliseconds;
    UINT weekday;
}U_TIME;
U_NAMESPACE_END(util)

class Util
{
public:
    enum { SECONDS_MINUTE = 60, SECONDS_HOUR = 3600, SECONDS_DAY = 3600*24 };
    static UINT  get_tick_count();
    static void  get_current_time(u::util::U_TIME* curtime);
    static char* module_folder();
    static char* module_name();
    static bool  shell_exec(const char* cmd, const char* param, const char* dir = NULL, int wait=0);
    // 执行命令，并返回结果
    static std::string  shell_exec_ex(const char* cmd, const char* param="", const char* dir="");
    static UINT  seconds(u::util::U_TIME* utm=NULL);
    static void  seconds2time(u::util::U_TIME* utm, UINT seconds);

    static int64_t get_monotonic();
    static int64_t get_mono_seconds();
    static int64_t get_timestamp();

    static UINT	get_week_day(int y, int m, int d);
};

U_NAMESPACE_END(u)


#endif
